package com.org.controller;

import com.org.entity.RecordAO;
import com.org.utils.VideoRecorder;
import io.swagger.annotations.Api;
import org.bytedeco.opencv.presets.opencv_core;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@Api(value = "视频录制",tags = {"用于视频录制的相关接口"})
@RestController
@RequestMapping("recorder")
public class RecoderController {

    @Value("${video.recorder.recorderTime}")
    private Long recorderTime;

    @Value("${video.recorder.file-name}")
    private String videoPath;


    public int recorder(@RequestBody RecordAO recordAO){

        int code=0;
        long l=System.currentTimeMillis();
        String name=l+"-"+recordAO.getCameraName();
        VideoRecorder videoRecorder=new VideoRecorder(name,true);
        videoRecorder.start();
        Long recordeTime=recordAO.getRecordeTime();
        Long reTime=this.recorderTime;
        if (recorderTime!=null){
            reTime=recorderTime;
            if (recorderTime<1000){
                reTime=1000L;
            }
        }

        videoRecorder.stop();
        System.out.println("录屏结束-----------------"+new Date());
        System.out.println("录屏保存在这个文件夹下:"+videoPath);

        return code;

    }


}
